package com.cdtye.itps.cms.service.job;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cdtye.common.mongocore.query.Page;
import com.cdtye.itps.cms.dao.anchor.vo.JcwAnchorVo;
import com.cdtye.itps.cms.dao.brain.vo.BrainResponseVo;
import com.cdtye.itps.cms.dao.defect.entity.JcwProblemDefectInfo;
import com.cdtye.itps.cms.dao.defect.vo.JcwProblemDefectInfoVo;
import com.cdtye.itps.cms.dao.dept.vo.JcDeptSiteVo;
import com.cdtye.itps.cms.dao.dept.vo.SysDeptVo;
import com.cdtye.itps.cms.dao.device.vo.*;
import com.cdtye.itps.cms.dao.dict.vo.SysDictionaryVo;
import com.cdtye.itps.cms.dao.direction.vo.JcDirectionVo;
import com.cdtye.itps.cms.dao.line.vo.JcSeclineVo;
import com.cdtye.itps.cms.dao.lineSite.vo.JcLineSiteVo;
import com.cdtye.itps.cms.dao.pillar.vo.JcwPillarVo;
import com.cdtye.itps.cms.dao.site.vo.JcSiteVo;
import com.cdtye.itps.cms.dao.tunnel.vo.JcTunnelVo;
import com.cdtye.itps.cms.service.datasysn.BrainHandleService;
import com.cdtye.itps.cms.service.datasysn.BrainService;
import com.cdtye.itps.cms.service.defect.SysTaskService;
import com.cdtye.itps.cms.util.DateUtils;
import com.cdtye.itps.models.base.model.entity.repair.SysTask;
import com.cdtye.itps.models.base.model.vo.basic.PillarVo;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RefreshScope
@Slf4j
@Service
public class SyncDataJobBrainService {

    @Autowired
    private SysTaskService sysTaskService;

    @Autowired
    private BrainService brainService;

    @Autowired
    private BrainHandleService brainHandleService;

    public final static int PAGE = 1;
    public final static int SIZE = 500;

    //时间戳
    public final static String INF_NAME_BRAIN_DICTIONARY = "brainJobDictionary";
    public final static String INF_NAME_BRAIN_DEPT = "brainJobDept";
    public final static String INF_NAME_BRAIN_SECLINE = "brainJobSecline";
    public final static String INF_NAME_BRAIN_DIRECTION = "brainJobDiretion";
    public final static String INF_NAME_BRAIN_SITE = "brainJobSite";
    public final static String INF_NAME_BRAIN_LINE_SITE = "brainJobLineSite";
    public final static String INF_NAME_BRAIN_DEPT_SITE = "brainJobDeptSite";
    public final static String INF_NAME_BRAIN_TUNNEL = "brainJobTunnel";
    public final static String INF_NAME_BRAIN_ANCHOR = "brainJobAnchor";
    public final static String INF_NAME_BRAIN_PILLAR = "brainJobPillar";
    public final static String INF_NAME_BRAIN_DEVICE_PILLAR = "brainJobDevicePillar";
    public final static String INF_NAME_BRAIN_DEVICE = "brainJobDevice";
    public final static String INF_NAME_BRAIN_DEVICECLASS = "brainJobDeviceclass";
    public final static String INF_NAME_BRAIN_DEVICE_CLASS_PERIOD = "brainJobDeviceClassPeriod";
    public final static String INF_NAME_BRAIN_PERIOD_MANAGE = "brainJobPeriodManage";

    //表名
    public final static String T_NAME_BRAIN_DATA_ELECT_DICTIONARY = "DataElectDictionary";
    public final static String T_NAME_BRAIN_DATA_ELECT_DEPT = "DataElectDept";
    public final static String T_NAME_BRAIN_DATA_ELECT_SECLINE = "DataElectSecline";
    public final static String T_NAME_BRAIN_DATA_ELECT_DIRECTION = "DataElectDirection";
    public final static String T_NAME_BRAIN_DATA_ELECT_SITE = "DataElectSite";
    public final static String T_NAME_BRAIN_DATA_ELECT_LINE_SITE = "DataElectLineSite";
    public final static String T_NAME_BRAIN_DATA_ELECT_DEPT_SITE = "DataElectDeptSite";
    public final static String T_NAME_BRAIN_DATA_ELECT_TUNNEL = "DataElectTunnel";
    public final static String T_NAME_BRAIN_DATA_ELECT_ANCHOR = "DataElectAnchor";
    public final static String T_NAME_BRAIN_DATA_ELECT_PILLAR = "DataElectPillar";
    public final static String T_NAME_BRAIN_DATA_ELECT_DEVICE_PILLARS = "DataElectDevicePillars";
    public final static String T_NAME_BRAIN_DATA_ELECT_DEVICE = "DataElectDevice";
    public final static String T_NAME_BRAIN_DATA_ELECT_DEVICECLASS = "DataElectDeviceClass";
    public final static String T_NAME_BRAIN_DATA_ELECT_DEVICE_CLASS_PERIOD = "DataElectDevicePeriod";
    public final static String T_NAME_BRAIN_DATA_ELECT_PERIOD_MANAGE= "DataElectPeriod";


    public void distributeTmisDictionary() {
        this.requestTmisDictionary(INF_NAME_BRAIN_DICTIONARY, T_NAME_BRAIN_DATA_ELECT_DICTIONARY);
    }

    public void distributeTmisDept() {
        this.requestTmisDept(INF_NAME_BRAIN_DEPT, T_NAME_BRAIN_DATA_ELECT_DEPT);
    }

    public void distributeTmisSecline() {
        this.requestTmisSecline(INF_NAME_BRAIN_SECLINE, T_NAME_BRAIN_DATA_ELECT_SECLINE);
    }

    public void distributeTmisDirection() {
        this.requestTmisDirection(INF_NAME_BRAIN_DIRECTION, T_NAME_BRAIN_DATA_ELECT_DIRECTION);
    }

    public void distributeTmisSite() {
        this.requestTmisSite(INF_NAME_BRAIN_SITE, T_NAME_BRAIN_DATA_ELECT_SITE);
    }

    public void distributeTmisLineSite() {
        this.requestTmisLineSite(INF_NAME_BRAIN_LINE_SITE, T_NAME_BRAIN_DATA_ELECT_LINE_SITE);
    }

    public void distributeTmisDeptSite() {
        this.requestTmisDeptSite(INF_NAME_BRAIN_DEPT_SITE, T_NAME_BRAIN_DATA_ELECT_DEPT_SITE);
    }

    public void distributeTmisTunnel() {
        this.requestTmisTunnel(INF_NAME_BRAIN_TUNNEL, T_NAME_BRAIN_DATA_ELECT_TUNNEL);
    }

    public void distributeTmisAnchor() {
        this.requestTmisAnchor(INF_NAME_BRAIN_ANCHOR, T_NAME_BRAIN_DATA_ELECT_ANCHOR);
    }

    public void distributeTmisPillar() {
        this.requestTmisPillar(INF_NAME_BRAIN_PILLAR, T_NAME_BRAIN_DATA_ELECT_PILLAR);
    }

    public void distributeTmisDevicePillars() {
        this.requestTmisDevicePillars(INF_NAME_BRAIN_DEVICE_PILLAR, T_NAME_BRAIN_DATA_ELECT_DEVICE_PILLARS);
    }

    public void distributeTmisDevice() {
        this.requestTmisDevice(INF_NAME_BRAIN_DEVICE, T_NAME_BRAIN_DATA_ELECT_DEVICE);
    }

    public void distributeTmisDeviceclass() {
        this.requestTmisDeviceclass(INF_NAME_BRAIN_DEVICECLASS, T_NAME_BRAIN_DATA_ELECT_DEVICECLASS);
    }

    public void distributeTmisDeviceClassPeriod() {
        this.requestTmisDeviceClassPeriod(INF_NAME_BRAIN_DEVICE_CLASS_PERIOD, T_NAME_BRAIN_DATA_ELECT_DEVICE_CLASS_PERIOD);
    }

    public void distributeTmisPeriodManage() {
        this.requestTmisPeriodManage(INF_NAME_BRAIN_PERIOD_MANAGE, T_NAME_BRAIN_DATA_ELECT_PERIOD_MANAGE);
    }



    //Tmis字典数据
    public void requestTmisDictionary(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:字典数据导入========================================");
        log.info("=================================开始任务:字典数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("字典任务不存在");
                log.info("字典任务不存在");
                return;
            }

            SysDictionaryVo vo = new SysDictionaryVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDictionary(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("字典Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("字典Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDictionary(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("字典Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("字典Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">字典Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>字典Tmis数据请求完成");
                log.error("ERROR==>>字典Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>字典Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>字典Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis部门数据
    public void requestTmisDept(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:部门数据导入========================================");
        log.info("=================================开始任务:部门数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("部门任务不存在");
                log.info("部门任务不存在");
                return;
            }

            SysDeptVo vo = new SysDeptVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDept(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("部门Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("部门Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDept(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("部门Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("部门Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">部门Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>部门Tmis数据请求完成");
                log.error("ERROR==>>部门Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>部门Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>部门Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis线路数据
    public void requestTmisSecline(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:线路数据导入========================================");
        log.info("=================================开始任务:线路数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("线路任务不存在");
                log.info("线路任务不存在");
                return;
            }

            JcSeclineVo vo = new JcSeclineVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageSecline(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("线路Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("线路Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageSecline(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("线路Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("线路Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">线路Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>线路Tmis数据请求完成");
                log.error("ERROR==>>线路Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>线路Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>线路Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis行别数据
    public void requestTmisDirection(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:行别数据导入========================================");
        log.info("=================================开始任务:行别数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("行别任务不存在");
                log.info("行别任务不存在");
                return;
            }

            JcDirectionVo vo = new JcDirectionVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDirection(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("行别Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("行别Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDirection(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("行别Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("行别Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">行别Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>行别Tmis数据请求完成");
                log.error("ERROR==>>行别Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>行别Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>行别Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis区站数据
    public void requestTmisSite(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:区站数据导入========================================");
        log.info("=================================开始任务:区站数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("区站任务不存在");
                log.info("区站任务不存在");
                return;
            }

            JcSiteVo vo = new JcSiteVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageSite(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("区站Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("区站Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageSite(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("区站Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("区站Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">区站Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>区站Tmis数据请求完成");
                log.error("ERROR==>>区站Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>区站Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>区站Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis线路区站数据
    public void requestTmisLineSite(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:线路区站数据导入========================================");
        log.info("=================================开始任务:线路区站数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("线路区站任务不存在");
                log.info("线路区站任务不存在");
                return;
            }

            JcLineSiteVo vo = new JcLineSiteVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageLineSite(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("线路区站Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("线路区站Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageLineSite(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("线路区站Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("线路区站Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">线路区站Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>线路区站Tmis数据请求完成");
                log.error("ERROR==>>线路区站Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>线路区站Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>线路区站Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis部门区站数据
    public void requestTmisDeptSite(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:部门区站数据导入========================================");
        log.info("=================================开始任务:部门区站数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("部门区站任务不存在");
                log.info("部门区站任务不存在");
                return;
            }

            JcDeptSiteVo vo = new JcDeptSiteVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDeptSite(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("部门区站Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("部门区站Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDeptSite(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("部门区站Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("部门区站Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">部门区站Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>部门区站Tmis数据请求完成");
                log.error("ERROR==>>部门区站Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>部门区站Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>部门区站Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis隧道数据
    public void requestTmisTunnel(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:隧道数据导入========================================");
        log.info("=================================开始任务:隧道数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("隧道任务不存在");
                log.info("隧道任务不存在");
                return;
            }

            JcTunnelVo vo = new JcTunnelVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageTunnel(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("隧道Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("隧道Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageTunnel(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("隧道Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("隧道Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">隧道Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>隧道Tmis数据请求完成");
                log.error("ERROR==>>隧道Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>隧道Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>隧道Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis锚段数据
    public void requestTmisAnchor(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:锚段数据导入========================================");
        log.info("=================================开始任务:锚段数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("锚段任务不存在");
                log.info("锚段任务不存在");
                return;
            }

            JcwAnchorVo vo = new JcwAnchorVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageAnchor(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("锚段Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("锚段Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageAnchor(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("锚段Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("锚段Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">锚段Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>锚段Tmis数据请求完成");
                log.error("ERROR==>>锚段Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>锚段Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>锚段Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis支柱数据
    public void requestTmisPillar(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:支柱数据导入========================================");
        log.info("=================================开始任务:支柱数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("支柱任务不存在");
                log.info("支柱任务不存在");
                return;
            }

            JcwPillarVo vo = new JcwPillarVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pagePillar(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("支柱Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("支柱Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pagePillar(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("支柱Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("支柱Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">支柱Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>支柱Tmis数据请求完成");
                log.error("ERROR==>>支柱Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>支柱Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>支柱Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis支柱设备数据
    public void requestTmisDevicePillars(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:支柱设备数据导入========================================");
        log.info("=================================开始任务:支柱设备数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("支柱设备任务不存在");
                log.info("支柱设备任务不存在");
                return;
            }

            JcwDevicePillarsVo vo = new JcwDevicePillarsVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDevicePillars(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("支柱设备Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("支柱设备Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDevicePillars(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("支柱设备Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("支柱设备Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">支柱设备Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>支柱设备Tmis数据请求完成");
                log.error("ERROR==>>支柱设备Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>支柱设备Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>支柱设备Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis设备数据
    public void requestTmisDevice(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:设备数据导入========================================");
        log.info("=================================开始任务:设备数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("设备任务不存在");
                log.info("设备任务不存在");
                return;
            }

            JcwDeviceVo vo = new JcwDeviceVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDevice(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("设备Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("设备Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDevice(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("设备Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("设备Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">设备Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>设备Tmis数据请求完成");
                log.error("ERROR==>>设备Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>设备Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>支柱Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis设备分类数据
    public void requestTmisDeviceclass(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:设备分类数据导入========================================");
        log.info("=================================开始任务:设备分类数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("设备分类任务不存在");
                log.info("设备分类任务不存在");
                return;
            }

            JcwDeviceclassVo vo = new JcwDeviceclassVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDeviceclass(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("设备分类Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("设备分类Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDeviceclass(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("设备分类Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("设备分类Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">设备分类Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>设备分类Tmis数据请求完成");
                log.error("ERROR==>>设备分类Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>设备分类Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>设备分类Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis设备周期数据
    public void requestTmisDeviceClassPeriod(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:设备周期数据导入========================================");
        log.info("=================================开始任务:设备周期数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("设备周期任务不存在");
                log.info("设备周期任务不存在");
                return;
            }

            JcwDeviceClassPeriodVo vo = new JcwDeviceClassPeriodVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pageDeviceClassPeriod(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("设备周期Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("设备周期Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pageDeviceClassPeriod(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("设备周期Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("设备周期Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">设备周期Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>设备周期Tmis数据请求完成");
                log.error("ERROR==>>设备周期Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>设备周期Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>设备周期Tmis数据系统错误：" + e.getMessage(), e);
        }
    }

    //Tmis检测周期数据
    public void requestTmisPeriodManage(String sysTaskInf, String tableName) {
        XxlJobLogger.log("=================================开始任务:检测周期数据导入========================================");
        log.info("=================================开始任务:检测周期数据导入========================================");
        try {

            Date lastUpdateTime = new Date();
            //获取上次作业时间
            SysTask sysTask = sysTaskService.findByInfName(sysTaskInf);
            if (sysTask != null) {
                lastUpdateTime = sysTask.getLastUpdateTime();
                //在数据库记录的最后修改时间的基础上减7天
                lastUpdateTime = DateUtils.addDay(lastUpdateTime, -7);
            } else {
                XxlJobLogger.log("检测周期任务不存在");
                log.info("检测周期任务不存在");
                return;
            }

            JcwPeriodManageVo vo = new JcwPeriodManageVo();
            vo.setPage(PAGE);
            vo.setSize(SIZE);
            vo.setUpdateDatetimeQuery(lastUpdateTime);
            //当接口同步时，删除状态的数据也需要查询出来
            vo.setDelFlag("toBrain");
            IPage<Map<String,Object>> pages = brainHandleService.pagePeriodManage(vo);

            //是否更新作业时间
            boolean sysTaskIf = true;
            if (pages.getTotal() > 0) {
                List<Map<String,Object>> list = pages.getRecords();
                XxlJobLogger.log("检测周期Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                log.info("检测周期Tmis数据获取到：" + (list == null ? 0 : list.size()) + "条数据");
                BrainResponseVo brainResponseVo = new BrainResponseVo(tableName, list);
                brainService.handleBrain(brainResponseVo);
                Long totalPage = Page.getTotalPage(pages.getTotal(), SIZE);
                for (Integer i = 2; i <= totalPage; i++) {
                    vo.setPage(i);
                    IPage<Map<String,Object>> pages2 = brainHandleService.pagePeriodManage(vo);
                    if (pages2.getTotal() > 0) {
                        List<Map<String,Object>> list2 = pages2.getRecords();
                        XxlJobLogger.log("检测周期Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        log.info("检测周期Tmis数据第"+i+"页获取到：" + (list2 == null ? 0 : list2.size()) + "条数据");
                        BrainResponseVo brainResponseVo2 = new BrainResponseVo(tableName, list2);
                        brainService.handleBrain(brainResponseVo2);
                    }
                }
                XxlJobLogger.log(">检测周期Tmis数据->请求完成，更新任务记录");

            } else {
                XxlJobLogger.log("ERROR==>检测周期Tmis数据请求完成");
                log.error("ERROR==>>检测周期Tmis数据请求完成");
                sysTaskIf = false;
            }
            //保存更新记录
            if (sysTaskIf){
                sysTask.setLastUpdateTime(new Date());
                sysTaskService.saveOrUpdate(sysTask);
            }
        } catch (Exception e) {
            XxlJobLogger.log("ERROR==>检测周期Tmis数据系统错误：" + e.getMessage());
            XxlJobLogger.log(e);
            log.error("ERROR==>检测周期Tmis数据系统错误：" + e.getMessage(), e);
        }
    }



}
